package p270jp.pxv.android.viewholder;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import java.util.Objects;
import p014ae.View$OnClickListenerC0090h7;
import p045be.View$OnClickListenerC1058b0;
import p045be.View$OnLongClickListenerC1110s;
import p134ei.AnalyticsScreenName;
import p144f1.C3017s;
import p184gi.AnalyticsParameter;
import p270jp.pxv.android.R;
import p270jp.pxv.android.legacy.model.PixivIllust;
import p270jp.pxv.android.view.IllustCardItemView;
import p270jp.pxv.android.view.PixivImageView;
import p521th.SolidItemViewHolder;
import p677zi.PixivImageLoader;

/* renamed from: jp.pxv.android.viewholder.IllustRankingTopItemViewHolder */
/* loaded from: classes2.dex */
public class IllustRankingTopItemViewHolder extends SolidItemViewHolder {
    private final View.OnClickListener clickListener;
    private final PixivIllust illust;
    private final IllustCardItemView illustCardItemView;
    private final int parentWidth;
    private final AnalyticsScreenName screenName;

    private IllustRankingTopItemViewHolder(PixivIllust pixivIllust, View view, int i, View.OnClickListener onClickListener, AnalyticsScreenName cVar) {
        super(view);
        this.illust = pixivIllust;
        this.parentWidth = i;
        this.illustCardItemView = (IllustCardItemView) view.findViewById(R.id.illust_card_item_view);
        this.clickListener = onClickListener;
        this.screenName = cVar;
    }

    public static IllustRankingTopItemViewHolder createViewHolder(PixivIllust pixivIllust, ViewGroup viewGroup, View.OnClickListener onClickListener, AnalyticsScreenName cVar) {
        return new IllustRankingTopItemViewHolder(pixivIllust, LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.view_holder_illust_card_item, viewGroup, false), viewGroup.getWidth(), onClickListener, cVar);
    }

    @Override // p521th.SolidItemViewHolder
    public void onBindViewHolder(int i) {
        String str;
        IllustCardItemView illustCardItemView = this.illustCardItemView;
        PixivIllust pixivIllust = this.illust;
        int i2 = this.parentWidth;
        Objects.requireNonNull(illustCardItemView);
        if (C3017s.m6470f(pixivIllust, false)) {
            illustCardItemView.setMuteCoverVisibility(0);
        } else {
            illustCardItemView.setMuteCoverVisibility(8);
            float f = 1.0f;
            if (((double) pixivIllust.getAspectRatioHeightOverWidth()) > 2.5d || ((double) pixivIllust.getAspectRatioWidthOverHeight()) > 2.5d) {
                str = pixivIllust.imageUrls.getSquareMedium();
            } else {
                str = pixivIllust.imageUrls.getMedium();
                f = pixivIllust.getAspectRatioHeightOverWidth();
            }
            illustCardItemView.f19533b.f21939s.setLayoutParams(new FrameLayout.LayoutParams(i2, (int) (((float) i2) * f)));
            PixivImageLoader aVar = illustCardItemView.f19534c;
            Context context = illustCardItemView.getContext();
            PixivImageView pixivImageView = illustCardItemView.f19533b.f21939s;
            aVar.m58h(context, str, pixivImageView, new p374nm.IllustCardItemView(illustCardItemView, pixivImageView));
            illustCardItemView.f19533b.f21944x.setText(pixivIllust.title);
            illustCardItemView.f19534c.m60f(illustCardItemView.getContext(), pixivIllust.user.profileImageUrls.getMedium(), illustCardItemView.f19533b.f21945y);
            illustCardItemView.f19533b.f21946z.setText(pixivIllust.user.name);
            illustCardItemView.f19533b.f21945y.setOnClickListener(new View$OnClickListenerC0090h7(illustCardItemView, pixivIllust, 6));
            illustCardItemView.setOnLongClickListener(new View$OnLongClickListenerC1110s(pixivIllust, 1));
            illustCardItemView.f19533b.f21941u.setWork(pixivIllust);
            if (1 < pixivIllust.pageCount) {
                illustCardItemView.f19533b.f21942v.setVisibility(0);
                illustCardItemView.f19533b.f21943w.setText(String.valueOf(pixivIllust.pageCount));
            } else {
                illustCardItemView.f19533b.f21943w.setVisibility(8);
            }
            if (pixivIllust.getIllustType() == PixivIllust.Type.UGOIRA) {
                illustCardItemView.f19533b.f21937q.setVisibility(0);
            } else {
                illustCardItemView.f19533b.f21937q.setVisibility(8);
            }
            if (pixivIllust.getIllustType() != PixivIllust.Type.MANGA || pixivIllust.series == null) {
                illustCardItemView.f19533b.f21940t.setVisibility(8);
                illustCardItemView.f19533b.f21940t.setOnClickListener(null);
            } else {
                illustCardItemView.f19533b.f21940t.setVisibility(0);
                illustCardItemView.f19533b.f21940t.setOnClickListener(new View$OnClickListenerC1058b0(illustCardItemView, pixivIllust, 3));
            }
        }
        this.illustCardItemView.setAnalyticsParameter(new AnalyticsParameter(this.screenName, null, 0));
        this.illustCardItemView.setOnClickListener(this.clickListener);
    }
}
